package app.auto.runner.base.utility;

import android.app.Activity;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;

import app.auto.runner.base.intf.FunCallback;

/**
 * Created by hp on 2018/4/2.
 */

public class HandlerUtil {
    public static void sendEmptymessage(final Context aty, final FunCallback cb) {
        new Handler(Looper.getMainLooper(), new Handler.Callback() {
            @Override
            public boolean handleMessage(Message msg) {
                cb.setParam(aty);
                cb.simpleRun(aty);
                cb.onCallback(aty,null);
                return false;
            }
        }).sendEmptyMessage(0);
    }

    public static void sendEmptymessageDelayed(final Activity aty, long delayed,final FunCallback cb) {
        new Handler(Looper.getMainLooper(), new Handler.Callback() {
            @Override
            public boolean handleMessage(Message msg) {
                cb.setParam(aty);
                cb.simpleRun(aty);
                return false;
            }
        }).sendEmptyMessageDelayed(0,delayed);


    }
}
